/**
 * Created by luckyjing on 16/3/27.
 */
var mongoose = require('mongoose'),
    Schema = mongoose.Schema;
var toolSchema = new Schema({
    name: {
        type: String,
        required: true
    },
    type: {
        type: String,
        required: true
    },
    left: {
        type: Number,
        required: true
    },
    rent: {
        type: Number,
        default: 0
    },
    company: {
        type: String,
        required: true
    },
    section: {
        type: String,
        required: true
    }
});
toolSchema.virtual('total').get(function () {
    return this.left + this.rent;
});
toolSchema.set('toJSON', {getters: true, virtuals: true});
mongoose.model('Tool', toolSchema);